package api.rowan.dubbocontroller.controller;

import api.rowan.pojo.Pet;
import api.rowan.pojo.Query;
import api.rowan.pojo.User;
import api.rowan.service.PetService;
import api.rowan.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

@Api(value = "User",tags={"用户模块"})
@RestController
public class UserController {

    @DubboReference(check = false)
    private UserService userService;
    @DubboReference(check = false)
    private PetService petService;

//    @ApiImplicitParam(name = "name",value = "姓名",required = true)
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = User.class)
    })
    @ApiOperation(value = "获取默认用户")
    @PostMapping("/default-user")
    public User getDefault(@RequestBody Query query){
        System.out.println(query);
        User user = userService.getUser(query);
        user.setBirthday(query.getDate());
        return user;
    }

    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = Pet.class)
    })
    @ApiOperation(value = "拥有宠物")
    @GetMapping("/havePets")
    public Pet getPets(Query query){
        System.out.println(query);
        Pet pet = petService.getPet();
        return pet;
    }


}
